<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title th:text="${canteen.name + ' - 校园食堂点评系统'}">食堂详情 - 校园食堂点评系统</title>
    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
    <link rel="stylesheet" th:href="@{/front/css/style.css}">
    <style>
        .canteen-detail {
            margin-top: 30px;
            padding: 30px 20px;
            box-shadow: 0 8px 40px rgb(185 147 147 / 15%);
            background: #ffffff;
            border-radius: 10px;
        }
        .canteen-header {
            display: flex;
            gap: 30px;
            margin-bottom: 40px;
            padding: 20px;
            background: #f8f9fa;
            border-radius: 10px;
        }
        .canteen-cover {
            flex: 0 0 400px;
            height: 300px;
        }
        .canteen-cover img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            border-radius: 10px;
        }
        .canteen-info {
            flex: 1;
        }
        .canteen-info h1 {
            font-size: 32px;
            color: #333;
            margin-bottom: 20px;
        }
        .meta-info {
            margin-bottom: 20px;
        }
        .info-item {
            margin-bottom: 15px;
            color: #666;
            font-size: 16px;
        }
        .info-item .label {
            color: #999;
            margin-right: 10px;
            font-weight: 500;
        }
        .status-open {
            color: #52c41a;
            font-weight: bold;
        }
        .status-closed {
            color: #ff4d4f;
            font-weight: bold;
        }
        .description {
            color: #666;
            line-height: 1.8;
            font-size: 16px;
            padding: 20px;
            background: #f8f9fa;
            border-radius: 8px;
        }
        .store-list {
            margin-top: 40px;
        }
        .store-list h2 {
            font-size: 24px;
            color: #333;
            margin-bottom: 30px;
            text-align: center;
            position: relative;
            padding-bottom: 10px;
        }
        .store-list h2:after {
            content: '';
            position: absolute;
            left: 50%;
            transform: translateX(-50%);
            bottom: 0;
            width: 50px;
            height: 3px;
            background: #4a90e2;
        }
        .store-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
            gap: 25px;
            padding: 20px;
        }
        .store-item {
            background: #fff;
            border-radius: 10px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            overflow: hidden;
            transition: all 0.3s ease;
        }
        .store-item:hover {
            transform: translateY(-5px);
            box-shadow: 0 5px 20px rgba(0,0,0,0.15);
        }
        .store-image {
            height: 180px;
            overflow: hidden;
        }
        .store-image img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }
        .store-info {
            padding: 20px;
        }
        .store-info h3 {
            margin: 0 0 15px;
            color: #333;
            font-size: 18px;
        }
        .store-score {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .score {
            color: #ff6b6b;
            font-weight: bold;
        }
        .comment-count {
            color: #666;
        }
        .lazy-load {
            opacity: 0;
            transition: opacity 0.3s ease-in;
        }
        .lazy-load.loaded {
            opacity: 1;
        }
    </style>
</head>
<body>
<div th:replace="front/common :: header"></div>

<div class="container">
    <div class="canteen-detail">
        <div class="canteen-header">
            <div class="canteen-cover">
                <img th:src="${canteen.photo}" th:alt="${canteen.name}" class="lazy-load">
            </div>
            <div class="canteen-info">
                <h1 th:text="${canteen.name}">食堂名称</h1>
                <div class="meta-info">
                    <div class="info-item">
                        <span class="label">营业时间：</span>
                        <span th:text="${canteen.businessTime}">营业时间</span>
                    </div>
                    <div class="info-item">
                        <span class="label">楼层数：</span>
                        <span th:text="${canteen.floorCount + '层'}">楼层</span>
                    </div>
                    <div class="info-item">
                        <span class="label">地址：</span>
                        <span th:text="${canteen.address}">地址</span>
                    </div>
                    <div class="info-item">
                        <span class="label">访问量：</span>
                        <span th:text="${canteen.viewSize}">访问量</span>
                    </div>
                    <div class="info-item">
                        <span class="label">状态：</span>
                        <span th:text="${canteen.status == 1 ? '营业中' : '休息中'}" 
                              th:class="${canteen.status == 1 ? 'status-open' : 'status-closed'}">
                            状态
                        </span>
                    </div>
                </div>
                <div class="description" th:text="${canteen.description}">
                    食堂描述
                </div>
            </div>
        </div>

        <!-- 店铺列表 -->
        <div class="store-list">
            <h2>店铺列表</h2>
            <div class="store-grid">
                <div class="store-item" th:each="store : ${stores}">
                    <a th:href="@{'/store/' + ${store.id}}">
                        <div class="store-image">
                            <img th:src="${store.photo}" th:alt="${store.name}" class="lazy-load">
                        </div>
                        <div class="store-info">
                            <h3 th:text="${store.name}">店铺名称</h3>
                            <div class="store-score">
                                <span class="score" th:text="${'评分：' + store.score}">评分</span>
                                <span class="comment-count" th:text="${'评价：' + store.commentSize}">评价数</span>
                            </div>
                        </div>
                    </a>
                </div>
            </div>
        </div>
    </div>
</div>

<div th:replace="front/common :: footer"></div>

<!-- 添加图片延迟加载脚本 -->
<script>
document.addEventListener('DOMContentLoaded', function() {
    let lazyImages = [].slice.call(document.querySelectorAll("img.lazy-load"));

    if ("IntersectionObserver" in window) {
        let lazyImageObserver = new IntersectionObserver(function(entries, observer) {
            entries.forEach(function(entry) {
                if (entry.isIntersecting) {
                    let lazyImage = entry.target;
                    lazyImage.classList.add("loaded");
                    lazyImageObserver.unobserve(lazyImage);
                }
            });
        });

        lazyImages.forEach(function(lazyImage) {
            lazyImageObserver.observe(lazyImage);
        });
    }
});
</script>
</body>
</html> 